package it.sandler.android.database;


import java.util.ArrayList;

/**
 * You can do what ever you want to do with SandlerDB.<br>
 * There are no restrictions. You can use SandlerDB for commercial use.<br>
 * <br>
 * Circle me on Google+: http://gplus.to/roberthahn<br>
 * SandlerDB on Google Code: http://code.google.com/p/sandler-db-for-android/<br>
 * <br>
 * Date: 04/16/2012
 * 
 * @author Robert Hahn
 * 
 */
public class SandlerList<T extends SandlerEntity> {

	private ArrayList<T> content = new ArrayList<T>();
	private final SandlerEntity entity;
	
	protected SandlerList(SandlerEntity entity) {
		this.entity = entity;
	}

	public final boolean add(T item) {
		entity.setChanged(true);
		return content.add(item);
	}

	protected final ArrayList<T> get() {
		return content;
	}

	public final T get(int index) {
		return content.get(index);
	}

	public final void add(int index, T item) {
		entity.setChanged(true);
		content.add(index, item);
	}

	public final void clear() {
		entity.setChanged(true);
		content.clear();
	}

	public final T set(int index, T item) {
		entity.setChanged(true);
		return content.set(index, item);
	}

	public final T remove(int index) {
		entity.setChanged(true);
		return content.remove(index);
	}

	public final boolean remove(Object object) {
		entity.setChanged(true);
		return content.remove(object);
	}

}
